package dao;

import java.util.List;

import entity.Client;

public class ClientDao {

	public List<Client> select(String where) {
		return DbHepler.executeQuery("select * from Client "+where, Client.class);
	}
	
	
	public int insert(Client model) {
		return DbHepler.executeUpdate("insert into Client (name,sex,tel,code,checkin_id) values(?,?,?,?,?)", model.getName(),model.getSex(),model.getTel(),model.getCode(),model.getCheckin_id());
	}
	
	public int update(Client model) {
		return DbHepler.executeUpdate("update Client set name=?,sex=?,tel=? where id=?",model.getName(),model.getSex(),model.getTel(), model.getId());
	}
	
	
	public int delete(int id) {
		return DbHepler.executeUpdate("delete from Client where id=?", id);
	}
	
	public Client getbyid(int id) {
		List<Client> list=DbHepler.executeQuery("select * from Client where id=?", Client.class,id);
		return list.get(0);
	}
	
}
